home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Source Code / Visual Basic Source Code.iso / vbsource / close-1r / progress.bas < prev    next >
Encoding:
BASIC Source File  |  1999-08-12  |  1.1 KB  |  43 lines

  1. Attribute VB_Name = "ProgressBAR"
  2. Sub Progress(OBJ As PictureBox, ByVal Current As Integer, _
  3.     max As Integer, Optional Caption As String)
  4.  
  5. '*************************************************************
  6. 'Draws progress bar in a picture box
  7. Dim Percent As String
  8. Dim Tmp As Long
  9. '*************************************************************
  10.  
  11. If Not OBJ.AutoRedraw Then
  12.     OBJ.AutoRedraw = -1
  13. End If
  14. OBJ.Cls
  15.     
  16. Tmp = Current / max * 100
  17. If Caption = "" Then
  18.     Percent = Format(Str(Tmp), "!@@@") + "%"
  19.   ElseIf Left(Caption, 1) = "%" Then
  20.     Percent = Mid(Caption, 2, Len(Caption) - 2) + " " + Format(Str(Tmp), "!@@@") + "%"
  21.   Else
  22.     Percent = Caption
  23. End If
  24.     
  25. If Tmp = 0 Then
  26.     OBJ.ScaleWidth = max
  27.     OBJ.DrawMode = 10
  28.     OBJ.Font.Bold = True
  29.     OBJ.ForeColor = RGB(0, 0, 255)
  30. End If
  31.     
  32. 'Centre Text in picture box
  33. OBJ.CurrentX = OBJ.ScaleWidth / 2 - OBJ.TextWidth(Percent) / 2
  34. OBJ.CurrentY = (OBJ.ScaleHeight - OBJ.TextHeight(Current)) / 2
  35. OBJ.Print Percent
  36.     
  37. OBJ.Line (0, 0)-(Current, OBJ.ScaleWidth), , BF
  38. OBJ.Refresh
  39. DoEvents
  40.     
  41. If Tmp = 100 Then OBJ.Cls
  42. End Sub
  43.